package com.wakala.employment.fragment.message;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.wakala.employment.R;
import com.wakala.employment.adapter.bean.OptionBean;
import com.wakala.employment.adapter.bean.TabEntity;
import com.wakala.employment.core.BaseFragment;
import com.wakala.employment.databinding.FragmentInteractBinding;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.widget.actionbar.TitleBar;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link InteractFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
@Page(anim = CoreAnim.none)
public class InteractFragment extends BaseFragment<FragmentInteractBinding> implements View.OnClickListener {

    private CommonTabLayout tlMessageNav = null;

    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();

    private final String[] mTitles = {
            "看过我", "我看过", "评价"
    };
    private int[] mIconUnselectIds = {
            R.drawable.icon_star, R.drawable.icon_star,
            R.drawable.icon_star, R.drawable.icon_star};
    private int[] mIconSelectIds = {
            R.drawable.icon_star_fill_king, R.drawable.icon_star_fill_king,
            R.drawable.icon_star_fill_king, R.drawable.icon_star_fill_king};
    private List<OptionBean> list;
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public InteractFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment InteractFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static InteractFragment newInstance(String param1, String param2) {
        InteractFragment fragment = new InteractFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }

    }

    @NonNull
    @Override
    protected FragmentInteractBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
        return FragmentInteractBinding.inflate(inflater, container, attachToRoot);
    }

    @Override
    protected TitleBar initTitle() {
        return null;
    }



    @Override
    protected void initViews() {
        tlMessageNav = findViewById(R.id.tl_message_nav);
        list = new ArrayList<>();
        list.add( new OptionBean("0",mTitles[0]));
        list.add( new OptionBean("1",mTitles[1]));
        list.add( new OptionBean("2",mTitles[2]));

        for (int i = 0; i < mTitles.length; i++) {
            mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i]));
        }
        tlMessageNav.setTabData(mTabEntities);
        tlMessageNav.setCurrentTab(0);
        //getMessageList(tlMessageNav.getCurrentTab());
        tlMessageNav.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
               // getMessageList(position);
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
    }

    @Override
    protected void initListeners() {
        super.initListeners();
    }


    @Override
    public void onClick(View view) {

    }
}